<template>
  <!--  template中书写组建的结构-->
  <header>
    <div class="l-content">
      <!--      plain图标镂空-->
      <el-button @click="handleMenu" plain icon="el-icon-menu" size="mini"></el-button>
      <h3 style="color: #ffffff">首页</h3>
    </div>
    <div class="r-content">
      <el-dropdown trigger="click" size="mini">
        <span>
          <img class="user" :src="userImg">
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
// script中书写组件交互相关的代码(数据、方法等)
export default {
  name: "CommonHeader",
  data() {
    return {
      userImg: require('@/assets/images/user.png'),
      isCollapse: true,
      // b:'231'
    }
  },
  methods: {
    // 点击事件发生   isCollapse取反  并通过全局事件总线传值
    handleMenu() {
      this.isCollapse = !this.isCollapse
      return this.$bus.$emit('hello', this.isCollapse)
    }
  },
}
</script>

<style lang="less" scoped>
/*style书写组建的样式*/
header {
  display: flex;
  height: 100%;
  justify-content: space-between;
  align-items: center;

  .l-content {
    display: flex;
    align-items: center;

    .el-button {
      margin-right: 20px;
    }
  }

  .r-content {
    .user {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  }
}
</style>